import axios from "@/utils/axios";

export const getMallData = data => {
  return axios.request({
    url: "front/shop/index",
    method: "get"
  });
};

export const getCategory = data => {
  return axios.request({
    url: "front/shop/getClassify",
    method: "get"
  });
};

export const getCategoryGoods = data => {
  return axios.request({
    url: "front/shop/getClassifyTwo",
    params: data,
    method: "get"
  });
};
export const searchGoods = data => {
  return axios.request({
    url: "front/shop/seekCommodity",
    params: data,
    method: "get"
  });
};

export const getVipGoods = data => {
  return axios.request({
    url: "front/shop/getVipCommodity?type=vip",
    params: data,
    method: "get"
  });
};

export const getCouponList = data => {
  return axios.request({
    url: "front/shop/getCoupon",
    params: data,
    method: "get"
  });
};

export const getCoupon = data => {
  return axios.request({
    url: "front/shop/claimCoupon",
    params: data,
    method: "get"
  });
};

export const getGoodsDetail = data => {
  return axios.request({
    url: "front/shop/getCommodityDetails",
    params: data,
    method: "get"
  });
};

export const getBrandGoods = data => {
  return axios.request({
    url: "front/shop/getBrandCommodity",
    params: data,
    method: "get"
  });
};

export const goodFavorite = data => {
  return axios.request({
    url: "front/shop/collect",
    data,
    method: "post"
  });
};

export const getGoodInventory = data => {
  return axios.request({
    url: "front/shop/getCommoditySpec",
    params: data,
    method: "get"
  });
};

export const getGoodComment = data => {
  return axios.request({
    url: "front/shop/getCommodityDetails?type=evaluate",
    params: data,
    method: "get"
  });
};

export const toPayment = data => {
  return axios.request({
    url: "front/order/createOrder",
    data,
    method: "post"
  });
};

export const orderSubmit = data => {
  return axios.request({
    url: "front/order/submitOrder",
    data,
    method: "post"
  });
};

export const orderPay = data => {
  return axios.request({
    url: "front/order/orderPay",
    data,
    method: "post"
  });
};

export const orderCancel = data => {
  return axios.request({
    url: "front/order/orderCancel",
    data,
    method: "post"
  });
};

export const orderDelete = data => {
  return axios.request({
    url: "front/order/orderDelete",
    data,
    method: "post"
  });
};

export const orderConfirm = data => {
  return axios.request({
    url: "front/order/orderConfirm",
    data,
    method: "post"
  });
};

export const getOrderDetail = data => {
  return axios.request({
    url: "front/order/orderDetail",
    params: data,
    method: "get"
  });
};

export const getRecommendGood = data => {
  return axios.request({
    url: "front/shop/recommend",
    params: data,
    method: "get"
  });
};

export const getNewGood = data => {
  return axios.request({
    url: "front/shop/recommend?type=new",
    params: data,
    method: "get"
  });
};

export const getShareInfo = data => {
  return axios.request({
    url: "front/shop/getCommodityDetails?type=share",
    params: data,
    method: "get"
  });
};

export const addToCart = data => {
  return axios.request({
    url: "front/shop/cartJoin",
    data,
    method: "post"
  });
};

export const getCartList = data => {
  return axios.request({
    url: "front/shop/cart?type=detail",
    params: data,
    method: "get"
  });
};

export const cartDelete = data => {
  return axios.request({
    url: "front/shop/cart?type=delete",
    data,
    method: "post"
  });
};

export const cartNumChange = data => {
  return axios.request({
    url: "front/shop/cart?type=change",
    data,
    method: "post"
  });
};

export const getBrandList = params => {
  return axios.request({
    url: "front/shop/getClassify?type=brand",
    params,
    method: "get"
  });
};

export const getExpressTrackDetail = params => {
  return axios.request({
    url: "front/order/logistics",
    params,
    method: "get"
  });
};

export const getPointGoodList = params => {
  return axios.request({
    url: "front/index/points?type=list",
    params,
    method: "get"
  });
};

export const agentApply = data => {
  return axios.request({
    url: "front/user/applyAgency",
    data,
    method: "post"
  });
};

export const getInviteCode = data => {
  return axios.request({
    url: "front/user/vipInfo?type=4",
    data,
    method: "get"
  });
};
// 获取图片魔方
export function getModuleList() {
  return axios.request({
    url: 'front/imageModuleList',
    method: 'get'
  })
}
// 获取积分
export function getIntegral(commodity_id, invite_code) {
  return axios.request({
    url: 'front/shop/shareCommodityGetPoint',
    method: 'post',
    data: {commodity_id, invite_code}
  })
}
